#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Cashflows/FloatingRateCoupon.h>
#pragma unmanaged 
#include <ql\cashflows\capflooredcoupon.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL::Indexes;
using namespace Cephei::QL::Termstructures;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Cashflows {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ICappedFlooredCoupon
	public ref class CCappedFlooredCoupon : 
            public CFloatingRateCoupon,
            public Cephei::QL::Cashflows::ICappedFlooredCoupon
	{
	protected: 
		boost::shared_ptr<QuantLib::CappedFlooredCoupon>* _ppCappedFlooredCoupon;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CappedFlooredCoupon>* _phCappedFlooredCoupon;
#endif
		Object^ _CappedFlooredCouponOwner;     // reference to object that manages the storage for this object
	internal:
		CCappedFlooredCoupon (Cephei::QL::Cashflows::IFloatingRateCoupon^ underlying, Microsoft::FSharp::Core::FSharpOption<Double>^ cap, Microsoft::FSharp::Core::FSharpOption<Double>^ floor, Cephei::QL::Cashflows::IFloatingRateCouponPricer^ QL_Pricer);
        CCappedFlooredCoupon (boost::shared_ptr<QuantLib::CappedFlooredCoupon>& childNative, Object^ owner);
        CCappedFlooredCoupon (QuantLib::CappedFlooredCoupon& childNative, Object^ owner);
        CCappedFlooredCoupon (CCappedFlooredCoupon^ copy);
        CCappedFlooredCoupon (System::Type^ t);
#ifdef STRUCT
        CCappedFlooredCoupon (QuantLib::CappedFlooredCoupon childNative);
#endif       
#ifdef HANDLE
		CCappedFlooredCoupon (QuantLib::Handle<QuantLib::CappedFlooredCoupon>& childNative, Object^ owner);
		CCappedFlooredCoupon (QuantLib::Handle<QuantLib::CappedFlooredCoupon> childNative);
#endif
		virtual ~CCappedFlooredCoupon ();
		!CCappedFlooredCoupon ();

	internal:
		QuantLib::CappedFlooredCoupon& GetReference ();
		boost::shared_ptr<QuantLib::CappedFlooredCoupon>& GetShared ();
		QuantLib::CappedFlooredCoupon* GetPointer ();
        void SetCappedFlooredCoupon (boost::shared_ptr<QuantLib::CappedFlooredCoupon> native)
        {
            if (_ppCappedFlooredCoupon != NULL)
                delete _ppCappedFlooredCoupon;
            _ppCappedFlooredCoupon = new boost::shared_ptr<QuantLib::CappedFlooredCoupon> (native);
            SetFloatingRateCoupon (boost::dynamic_pointer_cast<QuantLib::FloatingRateCoupon> (*_ppCappedFlooredCoupon));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CappedFlooredCoupon>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Double Cap 
        {
		    virtual Double get () ;
        }
        property Double ConvexityAdjustment 
        {
		    virtual Double get () ;
        }
        property Double EffectiveCap 
        {
		    virtual Double get () ;
        }
        property Double EffectiveFloor 
        {
		    virtual Double get () ;
        }
        property Double Floor 
        {
		    virtual Double get () ;
        }
        property Boolean IsCapped 
        {
		    virtual Boolean get () ;
        }
        property Boolean IsFloored 
        {
		    virtual Boolean get () ;
        }
        property Double Rate 
        {
		    virtual Double get () ;
        }
		virtual Cephei::QL::Cashflows::ICappedFlooredCoupon^ SetPricer (Cephei::QL::Cashflows::IFloatingRateCouponPricer^ pricer) ;
        property Cephei::QL::Cashflows::ICappedFlooredCoupon^ Update 
        {
		    virtual Cephei::QL::Cashflows::ICappedFlooredCoupon^ get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CCappedFlooredCoupon_Factory : public System::MarshalByRefObject,  public ICappedFlooredCoupon_Factory
	{
	public:
        virtual ICappedFlooredCoupon^ Create (Cephei::QL::Cashflows::IFloatingRateCoupon^ underlying, Microsoft::FSharp::Core::FSharpOption<Double>^ cap, Microsoft::FSharp::Core::FSharpOption<Double>^ floor, Cephei::QL::Cashflows::IFloatingRateCouponPricer^ QL_Pricer);
    };
   
/*Cephei*/ } /*QL*/ } /*Cashflows */}
